package 代码随想录.贪心;

import java.util.Arrays;

public class a455分发饼干 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] g = {1, 2,};
        int[] s = {1, 2, 3};
        System.out.println(solution.findContentChildren(g, s));
    }

    static class Solution {
        public int findContentChildren(int[] g, int[] s) {
            Arrays.sort(g);
            Arrays.sort(s);
            int res = 0;
            int j = 0;
            for (int i = 0; i < s.length; i++) {
                if (s[i] >= g[j]) {
                    res++;
                    j++;
                    if (j == g.length) {
                        break;
                    }
                }
            }
            return res;
        }
    }
}
